Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TxProposalProcedures type to make invalid states irrepresentable #726

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Jan 14, 2025

Changelog

- description: |
    Update TxProposalProcedures type to make invalid states irrepresentable.
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
   - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
   - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Previously TxProposalProcedures was not guaranteeing the type consistency: when used, you could insert proposals only to its second argument without inserting it to the first. The logic in cardano-api relies on a fact that the first argument would contain a complete list of proposals, so this would introduce a bug.

This PR changes TxProposalProcedures constructor to make it contain a single ordered map instead of both ordered set and a witness map.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@carbolymer carbolymer self-assigned this Jan 29, 2025
@carbolymer carbolymer force-pushed the mgalazyn/refactor/replace-txproposalprocedure-with-pattern branch 4 times, most recently from 8c7adb6 to 3193e8c Compare February 4, 2025 10:52
@carbolymer carbolymer changed the title Replace TxProposalProcedure with a pattern Replace TxProposalProcedure with constructor a pattern Feb 4, 2025
@carbolymer carbolymer changed the title Replace TxProposalProcedure with constructor a pattern Replace TxProposalProcedure with constructor an unidirectional pattern Feb 4, 2025
@carbolymer carbolymer changed the title Replace TxProposalProcedure with constructor an unidirectional pattern Replace TxProposalProcedures unsafe constructor with an unidirectional pattern Feb 4, 2025
@carbolymer carbolymer marked this pull request as ready for review February 4, 2025 10:57
@carbolymer carbolymer force-pushed the mgalazyn/refactor/replace-txproposalprocedure-with-pattern branch from 3193e8c to 1616394 Compare February 4, 2025 11:02
@carbolymer carbolymer force-pushed the mgalazyn/refactor/replace-txproposalprocedure-with-pattern branch 3 times, most recently from dd422b5 to 567e8c2 Compare February 5, 2025 15:23
@carbolymer carbolymer changed the title Replace TxProposalProcedures unsafe constructor with an unidirectional pattern Update TxProposalProcedures type to make invalid states irrepresentable Feb 5, 2025
@carbolymer carbolymer requested a review from Jimbo4350 February 5, 2025 15:25
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍

-> BuildTxWith build (Map (L.ProposalProcedure (ShelleyLedgerEra era)) (ScriptWitness WitCtxStake era))
-- ^ a map of witnesses for the proposals. If the proposals are not added to the first constructor
-- parameter too, the sky will fall on your head.
=> OMap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly necessary for this PR but we ought to start adding haddocks as we go along for these types.

E.g

-- | A proposal procedure houses a governance action that is required to be voted into acceptance when submitted.

I'll be asking everyone in future PRs to potentially add succinct summaries to share the documentation load fairly.

@carbolymer carbolymer force-pushed the mgalazyn/refactor/replace-txproposalprocedure-with-pattern branch from 567e8c2 to fbade80 Compare February 5, 2025 15:52
@carbolymer carbolymer enabled auto-merge February 5, 2025 15:52
@carbolymer carbolymer added this pull request to the merge queue Feb 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 5, 2025
@carbolymer carbolymer merged commit 8b5f077 into master Feb 6, 2025
29 checks passed
@carbolymer carbolymer deleted the mgalazyn/refactor/replace-txproposalprocedure-with-pattern branch February 6, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants